/*
 * File: Ctrl.cpp
 *
 * Code generated for Simulink model 'Ctrl'.
 *
 * Model version                  : 1.180
 * Simulink Coder version         : 8.2 (R2012a) 29-Dec-2011
 * TLC version                    : 8.2 (Dec 29 2011)
 * C/C++ source code generated on : Sat May 05 21:57:05 2012
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: Texas Instruments->C2000
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "Ctrl.h"
#include "Ctrl_private.h"

/* Named constants for Chart: '<S1>/Chart' */
#define Ctrl_IN_AltMode                ((uint8_T)1U)
#define Ctrl_IN_Failed                 ((uint8_T)1U)
#define Ctrl_IN_FutureMode             ((uint8_T)2U)
#define Ctrl_IN_NO_ACTIVE_CHILD        ((uint8_T)0U)
#define Ctrl_IN_Off                    ((uint8_T)3U)
#define Ctrl_IN_Online                 ((uint8_T)2U)
#define Ctrl_IN_PWMThrust              ((uint8_T)4U)

/* Function for Chart: '<S1>/Chart' */
void CtrlModelClass::Ctrl_SetOutputs(real_T state)
{
  /* Graphical Function 'SetOutputs': '<S3>:21' */
  /* Transition: '<S3>:35' */
  /* Transition: '<S3>:36' */
  /*  All Off */
  Ctrl_B.CtrlOff = FALSE;
  Ctrl_B.CtrlPWMThrust = FALSE;
  Ctrl_B.CtrlAlt = FALSE;
  if (state == 0.0) {
    /* Transition: '<S3>:38' */
    /* Transition: '<S3>:43' */
    /*  Off */
    Ctrl_B.CtrlOff = TRUE;

    /* Transition: '<S3>:47' */
  } else if (state == 2.0) {
    /* Transition: '<S3>:96' */
    /* Transition: '<S3>:93' */
    /*  AltitudeHold */
    Ctrl_B.CtrlAlt = TRUE;

    /* Transition: '<S3>:95' */
  } else {
    if (state == 1.0) {
      /* Transition: '<S3>:40' */
      /* Transition: '<S3>:42' */
      /*  PWMThrust */
      Ctrl_B.CtrlPWMThrust = TRUE;

      /* Transition: '<S3>:49' */
    }
  }
}

/* Model step function */
void CtrlModelClass::step()
{
  real32_T rtb_y_h;
  real32_T rtb_y;
  real32_T rtb_Sum_g;
  real32_T rtb_Saturation_o;
  real32_T rtb_Sum_g_0;
  real32_T rtb_y_0;

  /* Outputs for Atomic SubSystem: '<Root>/Ctrl' */
  /* MATLAB Function: '<S2>/MATLAB Function' incorporates:
   *  Bias: '<S2>/Bias'
   *  Bias: '<S2>/Bias1'
   *  Inport: '<Root>/MagY'
   *  Inport: '<Root>/MagZ'
   *  Trigonometry: '<S2>/Trigonometric Function'
   */
  /* MATLAB Function 'Ctrl/Angleconverter/MATLAB Function': '<S7>:1' */
  /* '<S7>:1:3' */
  rtb_y_h = (real32_T)atan2(Ctrl_U.MagY + Ctrl_P.Bias_Bias, Ctrl_U.MagZ +
    Ctrl_P.Bias1_Bias) / 6.28318548F;
  rtb_y_h = (rtb_y_h - (real32_T)floor(rtb_y_h)) * 6.28318548F;

  /* Chart: '<S1>/Chart' incorporates:
   *  Inport: '<Root>/AckErrr'
   *  Inport: '<Root>/Mode'
   */
  /* Gateway: Ctrl/Chart */
  /* During: Ctrl/Chart */
  if ((int16_T)Ctrl_DWork.is_active_c1_Ctrl == 0) {
    /* Entry: Ctrl/Chart */
    Ctrl_DWork.is_active_c1_Ctrl = 1U;

    /* Entry Internal: Ctrl/Chart */
    Ctrl_DWork.is_active_SystemLogic = 1U;

    /* Entry Internal 'SystemLogic': '<S3>:12' */
    /* Transition: '<S3>:86' */
    Ctrl_DWork.is_SystemLogic = Ctrl_IN_Online;

    /* Entry Internal 'Online': '<S3>:2' */
    /* Transition: '<S3>:16' */
    if ((int16_T)Ctrl_DWork.is_Online != (int16_T)Ctrl_IN_Off) {
      Ctrl_DWork.is_Online = Ctrl_IN_Off;

      /* Entry 'Off': '<S3>:14' */
      Ctrl_B.AMode = 0UL;
    }
  } else {
    if ((int16_T)Ctrl_DWork.is_active_SystemLogic != 0) {
      /* During 'SystemLogic': '<S3>:12' */
      switch (Ctrl_DWork.is_SystemLogic) {
       case Ctrl_IN_Failed:
        /* During 'Failed': '<S3>:3' */
        if (Ctrl_U.AckErrr) {
          /* Transition: '<S3>:11' */
          Ctrl_B.Failed = FALSE;
          Ctrl_DWork.is_SystemLogic = Ctrl_IN_Online;

          /* Entry Internal 'Online': '<S3>:2' */
          /* Transition: '<S3>:16' */
          if ((int16_T)Ctrl_DWork.is_Online != (int16_T)Ctrl_IN_Off) {
            Ctrl_DWork.is_Online = Ctrl_IN_Off;

            /* Entry 'Off': '<S3>:14' */
            Ctrl_B.AMode = 0UL;
          }
        }
        break;

       case Ctrl_IN_Online:
        /* During 'Online': '<S3>:2' */
        Ctrl_SetOutputs((real_T)Ctrl_B.AMode);
        if ((Ctrl_U.Mode == 0UL) && (!((int16_T)Ctrl_DWork.is_Online == (int16_T)
              Ctrl_IN_Off))) {
          /* Transition: '<S3>:15' */
          /* Exit Internal 'Online': '<S3>:2' */
          Ctrl_DWork.is_Online = Ctrl_IN_NO_ACTIVE_CHILD;
          if ((int16_T)Ctrl_DWork.is_Online != (int16_T)Ctrl_IN_Off) {
            Ctrl_DWork.is_Online = Ctrl_IN_Off;

            /* Entry 'Off': '<S3>:14' */
            Ctrl_B.AMode = 0UL;
          }
        } else {
          switch (Ctrl_DWork.is_Online) {
           case Ctrl_IN_AltMode:
            break;

           case Ctrl_IN_FutureMode:
            break;

           case Ctrl_IN_Off:
            /* During 'Off': '<S3>:14' */
            if (Ctrl_U.Mode == 1UL) {
              /* Transition: '<S3>:17' */
              Ctrl_DWork.is_Online = Ctrl_IN_PWMThrust;

              /* Entry 'PWMThrust': '<S3>:13' */
              Ctrl_B.AMode = 1UL;
            } else if (Ctrl_U.Mode == 2UL) {
              /* Transition: '<S3>:89' */
              Ctrl_DWork.is_Online = Ctrl_IN_AltMode;

              /* Entry 'AltMode': '<S3>:87' */
              Ctrl_B.AMode = 2UL;
            } else {
              if (Ctrl_U.Mode == 3UL) {
                /* Transition: '<S3>:90' */
                Ctrl_DWork.is_Online = Ctrl_IN_FutureMode;

                /* Entry 'FutureMode': '<S3>:88' */
                Ctrl_B.AMode = 3UL;
              }
            }
            break;

           case Ctrl_IN_PWMThrust:
            break;

           default:
            Ctrl_DWork.is_Online = Ctrl_IN_NO_ACTIVE_CHILD;
            break;
          }
        }
        break;

       default:
        Ctrl_DWork.is_SystemLogic = Ctrl_IN_NO_ACTIVE_CHILD;
        break;
      }
    }
  }

  /* End of Chart: '<S1>/Chart' */

  /* Outputs for Enabled SubSystem: '<S1>/Off' incorporates:
   *  EnablePort: '<S4>/Enable'
   */
  if (Ctrl_B.CtrlOff) {
    /* Constant: '<S4>/Constant1' */
    Ctrl_B.PWM2 = Ctrl_P.Constant1_Value;

    /* Constant: '<S4>/Constant2' */
    Ctrl_B.PWM1 = Ctrl_P.Constant2_Value;
  }

  /* End of Outputs for SubSystem: '<S1>/Off' */

  /* Outputs for Enabled SubSystem: '<S1>/PWMThrust' incorporates:
   *  EnablePort: '<S5>/Enable'
   */
  if (Ctrl_B.CtrlPWMThrust) {
    if (!Ctrl_DWork.PWMThrust_MODE) {
      /* InitializeConditions for DiscreteIntegrator: '<S8>/Integrator' */
      Ctrl_DWork.Integrator_DSTATE_n = Ctrl_P.Integrator_IC;
      Ctrl_DWork.PWMThrust_MODE = TRUE;
    }

    /* MATLAB Function: '<S5>/MATLAB Function' incorporates:
     *  Inport: '<Root>/YawRef'
     *  Sum: '<S5>/Sum3'
     */
    /* MATLAB Function 'Ctrl/PWMThrust/MATLAB Function': '<S10>:1' */
    /* '<S10>:1:3' */
    rtb_y = (Ctrl_U.YawRef - rtb_y_h) / 6.28318548F;
    rtb_y = (rtb_y - (real32_T)floor(rtb_y)) * 6.28318548F;
    if ((real_T)rtb_y > 3.1415926535897931) {
      /* '<S10>:1:4' */
      /* '<S10>:1:5' */
      rtb_y -= 6.28318548F;
    }

    /* End of MATLAB Function: '<S5>/MATLAB Function' */

    /* Gain: '<S9>/Proportional Gain' */
    rtb_y *= Ctrl_P.ProportionalGain_Gain;

    /* Saturate: '<S9>/Saturation' */
    if (rtb_y >= Ctrl_P.Saturation_UpperSat) {
      rtb_y = Ctrl_P.Saturation_UpperSat;
    } else {
      if (rtb_y <= Ctrl_P.Saturation_LowerSat) {
        rtb_y = Ctrl_P.Saturation_LowerSat;
      }
    }

    /* Sum: '<S5>/Sum2' incorporates:
     *  Inport: '<Root>/dYaw'
     *  Saturate: '<S9>/Saturation'
     */
    rtb_y -= Ctrl_U.dYaw;

    /* Sum: '<S8>/Sum' incorporates:
     *  DiscreteIntegrator: '<S8>/Integrator'
     *  Gain: '<S8>/Proportional Gain'
     */
    rtb_Sum_g = Ctrl_P.ProportionalGain_Gain_h * rtb_y +
      Ctrl_DWork.Integrator_DSTATE_n;

    /* Saturate: '<S8>/Saturation' */
    if (rtb_Sum_g >= Ctrl_P.Saturation_UpperSat_h) {
      rtb_Saturation_o = Ctrl_P.Saturation_UpperSat_h;
    } else if (rtb_Sum_g <= Ctrl_P.Saturation_LowerSat_i) {
      rtb_Saturation_o = Ctrl_P.Saturation_LowerSat_i;
    } else {
      rtb_Saturation_o = rtb_Sum_g;
    }

    /* End of Saturate: '<S8>/Saturation' */

    /* Gain: '<S8>/Integral Gain' */
    rtb_y *= Ctrl_P.IntegralGain_Gain;

    /* Sum: '<S5>/Sum' incorporates:
     *  Inport: '<Root>/PWMSet'
     */
    Ctrl_B.PWM1 = Ctrl_U.PWMSet + rtb_Saturation_o;

    /* Sum: '<S5>/Sum1' incorporates:
     *  Inport: '<Root>/PWMSet'
     */
    Ctrl_B.PWM2 = Ctrl_U.PWMSet - rtb_Saturation_o;

    /* Signum: '<S11>/SignPreSat' */
    if (rtb_Sum_g < 0.0F) {
      rtb_Sum_g_0 = -1.0F;
    } else if (rtb_Sum_g > 0.0F) {
      rtb_Sum_g_0 = 1.0F;
    } else {
      rtb_Sum_g_0 = rtb_Sum_g;
    }

    /* Signum: '<S11>/SignPreIntegrator' */
    if (rtb_y < 0.0F) {
      rtb_y_0 = -1.0F;
    } else if (rtb_y > 0.0F) {
      rtb_y_0 = 1.0F;
    } else {
      rtb_y_0 = rtb_y;
    }

    /* Switch: '<S8>/Switch' incorporates:
     *  Constant: '<S8>/Constant'
     *  Logic: '<S11>/AND'
     *  RelationalOperator: '<S11>/Equal'
     *  RelationalOperator: '<S11>/NotEqual'
     *  Signum: '<S11>/SignPreIntegrator'
     *  Signum: '<S11>/SignPreSat'
     */
    if ((rtb_Sum_g != rtb_Saturation_o) && (rtb_Sum_g_0 == rtb_y_0)) {
      rtb_y = Ctrl_P.Constant_Value;
    }

    /* End of Switch: '<S8>/Switch' */

    /* Update for DiscreteIntegrator: '<S8>/Integrator' */
    Ctrl_DWork.Integrator_DSTATE_n += Ctrl_P.Integrator_gainval * rtb_y;
  } else {
    if (Ctrl_DWork.PWMThrust_MODE) {
      Ctrl_DWork.PWMThrust_MODE = FALSE;
    }
  }

  /* End of Outputs for SubSystem: '<S1>/PWMThrust' */

  /* Outputs for Enabled SubSystem: '<S1>/PWMThrust1' incorporates:
   *  EnablePort: '<S6>/Enable'
   */
  if (Ctrl_B.CtrlAlt) {
    if (!Ctrl_DWork.PWMThrust1_MODE) {
      /* InitializeConditions for DiscreteIntegrator: '<S12>/Integrator' */
      Ctrl_DWork.Integrator_DSTATE = Ctrl_P.Integrator_IC_e;
      Ctrl_DWork.PWMThrust1_MODE = TRUE;
    }

    /* Gain: '<S13>/Proportional Gain' incorporates:
     *  Inport: '<Root>/YawRef'
     *  Sum: '<S6>/Sum3'
     */
    rtb_y = (Ctrl_U.YawRef - rtb_y_h) * Ctrl_P.ProportionalGain_Gain_f;

    /* Saturate: '<S13>/Saturation' */
    if (rtb_y >= Ctrl_P.Saturation_UpperSat_e) {
      rtb_y = Ctrl_P.Saturation_UpperSat_e;
    } else {
      if (rtb_y <= Ctrl_P.Saturation_LowerSat_o) {
        rtb_y = Ctrl_P.Saturation_LowerSat_o;
      }
    }

    /* Sum: '<S6>/Sum2' incorporates:
     *  Inport: '<Root>/dYaw'
     *  Saturate: '<S13>/Saturation'
     */
    rtb_y -= Ctrl_U.dYaw;

    /* Sum: '<S12>/Sum' incorporates:
     *  DiscreteIntegrator: '<S12>/Integrator'
     *  Gain: '<S12>/Proportional Gain'
     */
    rtb_Sum_g = Ctrl_P.ProportionalGain_Gain_a * rtb_y +
      Ctrl_DWork.Integrator_DSTATE;

    /* Saturate: '<S12>/Saturation' */
    if (rtb_Sum_g >= Ctrl_P.Saturation_UpperSat_m) {
      rtb_Saturation_o = Ctrl_P.Saturation_UpperSat_m;
    } else if (rtb_Sum_g <= Ctrl_P.Saturation_LowerSat_g) {
      rtb_Saturation_o = Ctrl_P.Saturation_LowerSat_g;
    } else {
      rtb_Saturation_o = rtb_Sum_g;
    }

    /* End of Saturate: '<S12>/Saturation' */

    /* Gain: '<S12>/Integral Gain' */
    rtb_y *= Ctrl_P.IntegralGain_Gain_o;

    /* Sum: '<S6>/Sum' incorporates:
     *  Inport: '<Root>/dYaw'
     */
    Ctrl_B.PWM1 = Ctrl_U.dYaw + rtb_Saturation_o;

    /* Sum: '<S6>/Sum1' incorporates:
     *  Inport: '<Root>/dYaw'
     */
    Ctrl_B.PWM2 = Ctrl_U.dYaw - rtb_Saturation_o;

    /* Signum: '<S14>/SignPreSat' */
    if (rtb_Sum_g < 0.0F) {
      rtb_Sum_g_0 = -1.0F;
    } else if (rtb_Sum_g > 0.0F) {
      rtb_Sum_g_0 = 1.0F;
    } else {
      rtb_Sum_g_0 = rtb_Sum_g;
    }

    /* Signum: '<S14>/SignPreIntegrator' */
    if (rtb_y < 0.0F) {
      rtb_y_0 = -1.0F;
    } else if (rtb_y > 0.0F) {
      rtb_y_0 = 1.0F;
    } else {
      rtb_y_0 = rtb_y;
    }

    /* Switch: '<S12>/Switch' incorporates:
     *  Constant: '<S12>/Constant'
     *  Logic: '<S14>/AND'
     *  RelationalOperator: '<S14>/Equal'
     *  RelationalOperator: '<S14>/NotEqual'
     *  Signum: '<S14>/SignPreIntegrator'
     *  Signum: '<S14>/SignPreSat'
     */
    if ((rtb_Sum_g != rtb_Saturation_o) && (rtb_Sum_g_0 == rtb_y_0)) {
      rtb_y = Ctrl_P.Constant_Value_f;
    }

    /* End of Switch: '<S12>/Switch' */

    /* Update for DiscreteIntegrator: '<S12>/Integrator' */
    Ctrl_DWork.Integrator_DSTATE += Ctrl_P.Integrator_gainval_n * rtb_y;
  } else {
    if (Ctrl_DWork.PWMThrust1_MODE) {
      Ctrl_DWork.PWMThrust1_MODE = FALSE;
    }
  }

  /* End of Outputs for SubSystem: '<S1>/PWMThrust1' */
  /* End of Outputs for SubSystem: '<Root>/Ctrl' */

  /* Outport: '<Root>/ActualMode' */
  Ctrl_Y.ActualMode = Ctrl_B.AMode;

  /* Outport: '<Root>/Failed' */
  Ctrl_Y.Failed = Ctrl_B.Failed;

  /* Outport: '<Root>/PWM1' */
  Ctrl_Y.PWM1 = Ctrl_B.PWM1;

  /* Outport: '<Root>/PWM2' */
  Ctrl_Y.PWM2 = Ctrl_B.PWM2;
}

/* Model initialize function */
void CtrlModelClass::initialize()
{
  /* Registration code */

  /* initialize error status */
  rtmSetErrorStatus(Ctrl_M, (NULL));

  /* block I/O */
  (void) memset(((void *) &Ctrl_B), 0,
                sizeof(BlockIO_Ctrl));

  /* states (dwork) */
  (void) memset((void *)&Ctrl_DWork, 0,
                sizeof(D_Work_Ctrl));

  /* external inputs */
  (void) memset((void *)&Ctrl_U, 0,
                sizeof(ExternalInputs_Ctrl));

  /* external outputs */
  (void) memset((void *)&Ctrl_Y, 0,
                sizeof(ExternalOutputs_Ctrl));

  /* Start for Atomic SubSystem: '<Root>/Ctrl' */
  /* Start for Enabled SubSystem: '<S1>/PWMThrust' */
  /* InitializeConditions for DiscreteIntegrator: '<S8>/Integrator' */
  Ctrl_DWork.Integrator_DSTATE_n = Ctrl_P.Integrator_IC;

  /* End of Start for SubSystem: '<S1>/PWMThrust' */

  /* Start for Enabled SubSystem: '<S1>/PWMThrust1' */
  /* InitializeConditions for DiscreteIntegrator: '<S12>/Integrator' */
  Ctrl_DWork.Integrator_DSTATE = Ctrl_P.Integrator_IC_e;

  /* VirtualOutportStart for Outport: '<S6>/PWMs' */
  Ctrl_B.PWM1 = Ctrl_P.PWMs_Y0_j[0];
  Ctrl_B.PWM2 = Ctrl_P.PWMs_Y0_j[1];

  /* End of Start for SubSystem: '<S1>/PWMThrust1' */
  /* End of Start for SubSystem: '<Root>/Ctrl' */

  /* Start for Outport: '<Root>/ActualMode' */
  Ctrl_Y.ActualMode = Ctrl_B.AMode;

  /* Start for Outport: '<Root>/Failed' */
  Ctrl_Y.Failed = Ctrl_B.Failed;

  /* Start for Outport: '<Root>/PWM1' */
  Ctrl_Y.PWM1 = Ctrl_B.PWM1;

  /* Start for Outport: '<Root>/PWM2' */
  Ctrl_Y.PWM2 = Ctrl_B.PWM2;

  /* InitializeConditions for Atomic SubSystem: '<Root>/Ctrl' */
  /* InitializeConditions for Chart: '<S1>/Chart' */
  Ctrl_DWork.is_active_SystemLogic = 0U;
  Ctrl_DWork.is_SystemLogic = 0U;
  Ctrl_DWork.is_Online = 0U;
  Ctrl_DWork.is_active_c1_Ctrl = 0U;
  Ctrl_B.AMode = 0UL;
  Ctrl_B.Failed = FALSE;
  Ctrl_B.CtrlOff = FALSE;
  Ctrl_B.CtrlPWMThrust = FALSE;
  Ctrl_B.CtrlAlt = FALSE;

  /* End of InitializeConditions for SubSystem: '<Root>/Ctrl' */
}

/* Model terminate function */
void CtrlModelClass::terminate()
{
  /* (no terminate code required) */
}

/* Constructor */
CtrlModelClass::CtrlModelClass()
{
  Parameters_Ctrl Ctrl_P_temp = {
    /*  Computed Parameter: PWMs_Y0
     * Referenced by: '<S4>/PWMs'
     */
    { 1000.0F, 1000.0F },
    1000.0F,                           /* Computed Parameter: Constant1_Value
                                        * Referenced by: '<S4>/Constant1'
                                        */
    1000.0F,                           /* Computed Parameter: Constant2_Value
                                        * Referenced by: '<S4>/Constant2'
                                        */

    /*  Computed Parameter: PWMs_Y0_i
     * Referenced by: '<S5>/PWMs'
     */
    { 1000.0F, 1000.0F },
    1.5F,                              /* Computed Parameter: ProportionalGain_Gain
                                        * Referenced by: '<S9>/Proportional Gain'
                                        */
    1.0F,                              /* Computed Parameter: Saturation_UpperSat
                                        * Referenced by: '<S9>/Saturation'
                                        */
    -1.0F,                             /* Computed Parameter: Saturation_LowerSat
                                        * Referenced by: '<S9>/Saturation'
                                        */
    80.0F,                             /* Computed Parameter: ProportionalGain_Gain_h
                                        * Referenced by: '<S8>/Proportional Gain'
                                        */
    0.01F,                             /* Computed Parameter: Integrator_gainval
                                        * Referenced by: '<S8>/Integrator'
                                        */
    0.0F,                              /* Computed Parameter: Integrator_IC
                                        * Referenced by: '<S8>/Integrator'
                                        */
    200.0F,                            /* Computed Parameter: Saturation_UpperSat_h
                                        * Referenced by: '<S8>/Saturation'
                                        */
    -200.0F,                           /* Computed Parameter: Saturation_LowerSat_i
                                        * Referenced by: '<S8>/Saturation'
                                        */
    200.0F,                            /* Computed Parameter: IntegralGain_Gain
                                        * Referenced by: '<S8>/Integral Gain'
                                        */
    0.0F,                              /* Computed Parameter: Constant_Value
                                        * Referenced by: '<S8>/Constant'
                                        */

    /*  Computed Parameter: PWMs_Y0_j
     * Referenced by: '<S6>/PWMs'
     */
    { 1000.0F, 1000.0F },
    3.0F,                              /* Computed Parameter: ProportionalGain_Gain_f
                                        * Referenced by: '<S13>/Proportional Gain'
                                        */
    1.0F,                              /* Computed Parameter: Saturation_UpperSat_e
                                        * Referenced by: '<S13>/Saturation'
                                        */
    -1.0F,                             /* Computed Parameter: Saturation_LowerSat_o
                                        * Referenced by: '<S13>/Saturation'
                                        */
    80.0F,                             /* Computed Parameter: ProportionalGain_Gain_a
                                        * Referenced by: '<S12>/Proportional Gain'
                                        */
    0.01F,                             /* Computed Parameter: Integrator_gainval_n
                                        * Referenced by: '<S12>/Integrator'
                                        */
    0.0F,                              /* Computed Parameter: Integrator_IC_e
                                        * Referenced by: '<S12>/Integrator'
                                        */
    200.0F,                            /* Computed Parameter: Saturation_UpperSat_m
                                        * Referenced by: '<S12>/Saturation'
                                        */
    -200.0F,                           /* Computed Parameter: Saturation_LowerSat_g
                                        * Referenced by: '<S12>/Saturation'
                                        */
    200.0F,                            /* Computed Parameter: IntegralGain_Gain_o
                                        * Referenced by: '<S12>/Integral Gain'
                                        */
    0.0F,                              /* Computed Parameter: Constant_Value_f
                                        * Referenced by: '<S12>/Constant'
                                        */
    -0.0867F,                          /* Computed Parameter: Bias_Bias
                                        * Referenced by: '<S2>/Bias'
                                        */
    0.29F                              /* Computed Parameter: Bias1_Bias
                                        * Referenced by: '<S2>/Bias1'
                                        */
  };                                   /* Modifiable parameters */

  /* Initialize tunable parameters */
  Ctrl_P = Ctrl_P_temp;

  /* Real-Time Model */
  Ctrl_M = &Ctrl_M_;
}

/* Destructor */
CtrlModelClass::~CtrlModelClass()
{
  /* Currently there is no destructor body generated.*/
}

/* Real-Time Model get method */
RT_MODEL_Ctrl * CtrlModelClass::getRTM() const
{
  return Ctrl_M;
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
